package com.inossem.warehousemanage_tv.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.inossem.warehousemanage_tv.R;
import com.inossem.warehousemanage_tv.bean.WelBean;

import java.util.List;

/**
 * 值班人员
 *
 * @author 詹建宇
 * @time on 2019/3/6 10:40
 * @email jianyu.zhan@inossem.com
 */
public class DutyAdapter extends BaseAdapter {

    private Context context;
    private List<WelBean.DutyListBean> list;

    public DutyAdapter(Context context, List<WelBean.DutyListBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.view_duty_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        WelBean.DutyListBean bean = list.get(position);
        holder.tvName.setText(bean.getUser_name());
        holder.tvTime.setText(bean.getDuty_time());

        return convertView;
    }

    class ViewHolder {
        private TextView tvName;
        private TextView tvTime;
        private View viewLine;

        public ViewHolder(View view) {
            tvName = view.findViewById(R.id.tv_name);
            tvTime = view.findViewById(R.id.tv_time);
            viewLine = view.findViewById(R.id.view_line);
            viewLine.setVisibility(View.VISIBLE);
        }
    }

}
